import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

public class NIOClient {

    public static String HOST = "127.0.0.1";

    public static void main(String[] args) throws IOException {

        SocketChannel socketChannel = SocketChannel.open();
        socketChannel.connect(new InetSocketAddress(HOST, NIOServer.PORT));

        ByteBuffer byteBuffer = ByteBuffer.allocateDirect(16*4);

        byteBuffer.put("hello word ！你好啊".getBytes());
//        byteBuffer.flip();

        while (byteBuffer.hasRemaining()){

            byteBuffer.flip();

            socketChannel.write(byteBuffer);
            System.out.println("拆包~~~！");
        }
        byteBuffer.clear();

        socketChannel.shutdownOutput();

        socketChannel.close();


    }

}
